<?php

namespace backend\controllers;

use yii;
use yii\web\Controller;
use backend\models\service\Bill;
use backend\behaviors\BillBehavior;
use yii\filters\AccessControl;

class BillController extends Controller
{
    /**
     * @inheritdoc
     */
    public function behaviors()
    {
        return [
            'access' => [
                'class' => AccessControl::className(),
                'rules' => [
                    [
                        'allow' => true,
                        'roles' => ['@'],
                    ],
//                    [
//                        'actions' => ['login', 'captcha'],
//                        'allow' => true,
//                        'roles' => ['?'],
//                    ],
                ],
            ],
        ];
    }
    public function actionIndex()
    {
        $model = new Bill();
        $model->attachBehavior('bill', new BillBehavior);
        $model->load(Yii::$app->request->queryParams);
        $get = Yii::$app->request->get();
        return $this->render('index', [
            'searchModel' => $model,
            'dataProvider' => $model->list_for_index(),
            'select' => array(
                'status' => isset($get['Bill']['status']) ? $get['Bill']['status'] : '',
                'type' => isset($get['Bill']['pay_type']) ? $get['Bill']['pay_type'] : '',
                'start' => isset($get['Bill']['start']) ? $get['Bill']['start'] : '',
                'end' => isset($get['Bill']['end']) ? $get['Bill']['end'] : '',
            ),
        ]);
    }

}
